//
//  DLFalseMineCellView.m
//  delongzhitou
//
//  Created by Mr.Wang on 2019/1/2.
//  Copyright © 2019 delongzhitou. All rights reserved.
//

#import "DLFalseMineCellView.h"
#import "DLModifyPasswordVC.h"
#import "DLOpinionReportVC.h"

@interface DLFalseMineCellView()

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *subTitleLabel;

@property (nonatomic, strong) UIImageView *rightArrowImgV;

@end

@implementation DLFalseMineCellView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        [self layoutSubControls];
        
        UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGes)];
        [self addGestureRecognizer:tapGes];
    }
    return self;
}
- (void) tapGes {
    if ([self.titleLabel.text isEqualToString:@"修改登录密码"]) {
        
        DLModifyPasswordVC *mpvc = [DLModifyPasswordVC new];
        [kuserManager.lastVc.navigationController pushViewController:mpvc animated:YES];
    } else if ([self.titleLabel.text isEqualToString:@"关于我们"]) {
        
        DLNormalWebVC *bvc = [DLNormalWebVC new];
        bvc.urlString = HTTPAboutUs;
        bvc.titleString = @"关于我们";
        bvc.webViewType = DLWebViewType_wholeUrl;
        [kuserManager.lastVc.navigationController pushViewController:bvc animated:YES];
    } else if ([self.titleLabel.text isEqualToString:@"意见反馈"]) {
        
        DLOpinionReportVC *orvc = [DLOpinionReportVC new];
        [kuserManager.lastVc.navigationController pushViewController:orvc animated:YES];
    }
}
- (void) layoutSubControls {
    UILabel *titleLabel = [UILabel new];
    titleLabel.frame = CGRectMake(19, 1.5, 140, 55);
    titleLabel.textColor = kDLNormalBlackColor;
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.font = kSystemFont(14);
    [self addSubview:titleLabel];
    self.titleLabel = titleLabel;
    //    titleLabel.backgroundColor = [UIColor redColor];
    
    UILabel *subTitleLabel = [UILabel new];
    subTitleLabel.frame = CGRectMake(titleLabel.right, titleLabel.top, kScreenWidth - titleLabel.width - 38 - 12.5, titleLabel.height);
    subTitleLabel.textColor = kColorRGB(180, 180, 180);
    subTitleLabel.textAlignment = NSTextAlignmentRight;
    subTitleLabel.font = kSystemFont(13);
    [self addSubview:subTitleLabel];
    self.subTitleLabel = subTitleLabel;
    //    subTitleLabel.backgroundColor = [UIColor orangeColor];
    
    UIImageView *rightArrowImgV = [UIImageView new];
    rightArrowImgV.frame = CGRectMake(subTitleLabel.right, 19, 20, 20);
    rightArrowImgV.image = [UIImage imageNamed:@"right_arrow"];
    [self addSubview:rightArrowImgV];
    self.rightArrowImgV = rightArrowImgV;
}

- (void) configSubControlsWithTitle:(NSString *)title andSubTitle:(NSString *)subTitle {
    
    self.titleLabel.text = title;
    self.subTitleLabel.text = subTitle;
    
    if ([subTitle isEqualToString:@"版本号"]) {
        self.subTitleLabel.text = [NSString stringWithFormat:@"v%@", APP_VERSION];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
